from flask import request

from domain.User import User
from handle.userHandle import userRegister,userLogin
from publicHandle.publicHandle import returnData


class apiUser():
    def __init__(self, app):
        @app.route("/register", methods=["POST"])
        def user_Register():
            username = request.values.get("username")
            account = request.values.get("account")
            password = request.values.get("password")
            print("232323")
            if (username and account and password):
                return userRegister(username, account, password)
            return returnData({}, "输入为空！", 400)

        @app.route("/login", methods=["POST"])
        def login():
            account = request.values.get("account")
            password = request.values.get("password")
            print(account)
            print(password)
            if (account and password):
                result = userLogin(account, password)
                print(result)
                return result
            return returnData({},"输入为空！",400)
